home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-SPAR.{_A / DELAY.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  940b  |  50 lines

  1. /* $Id: delay.h,v 1.7 1997/11/07 18:24:31 mj Exp $
  2.  * delay.h: Linux delay routines on the V9.
  3.  *
  4.  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu).
  5.  */
  6.  
  7. #ifndef __SPARC64_DELAY_H
  8. #define __SPARC64_DELAY_H
  9.  
  10. #ifdef __SMP__
  11. #include <asm/smp.h>
  12. #endif 
  13.  
  14. extern __inline__ void __delay(unsigned long loops)
  15. {
  16.     __asm__ __volatile__("
  17.     b,pt    %%xcc, 1f
  18.      cmp    %0, 0
  19.     .align    32
  20. 1:
  21.     bne,pt    %%xcc, 1b
  22.      subcc    %0, 1, %0
  23. "    : "=&r" (loops)
  24.     : "0" (loops)
  25.     : "cc");
  26. }
  27.  
  28. extern __inline__ void __udelay(unsigned long usecs, unsigned long lps)
  29. {
  30.     usecs *= 0x00000000000010c6UL;        /* 2**32 / 1000000 */
  31.  
  32.     __asm__ __volatile__("
  33.     mulx    %1, %2, %0
  34.     srlx    %0, 32, %0
  35. "    : "=r" (usecs)
  36.     : "r" (usecs), "r" (lps));
  37.  
  38.     __delay(usecs);
  39. }
  40.  
  41. #ifdef __SMP__
  42. #define __udelay_val cpu_data[smp_processor_id()].udelay_val
  43. #else
  44. #define __udelay_val loops_per_sec
  45. #endif
  46.  
  47. #define udelay(usecs) __udelay((usecs),__udelay_val)
  48.  
  49. #endif /* defined(__SPARC64_DELAY_H) */
  50.